/**
 * 关于页面
 * author wim
 */
import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:package_info/package_info.dart';
import 'package:panda/http/Api.dart';
import 'package:panda/http/HttpUtil.dart';
import '../base/Constant.dart';

class AboutUsPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return AboutUsView();
  }
}

class AboutUsView extends State<AboutUsPage> {
  String version = "";
  String content = "";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
      setState(() {
        version = packageInfo.version;
      });
    });
    getDetail();
  }

  getDetail() async {
    FormData formData = new FormData.fromMap({
      "article_id": "10",
    });
    Response<String> response =
        await HttpUtil().post(Api.GET_ARTICLE_DETAIL, data: formData);
    Map userMap = json.decode(response.data);
    print(userMap);
    setState(() {
      content = userMap['data']['article_msg']['content'];
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: AppBar(
        title: Text(
          '关于我们',
          style: TextStyle(color: black, fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE)),
        ),
        elevation:0.2,
        backgroundColor: white,
        iconTheme: new IconThemeData(color: black_99),
        brightness: Brightness.light,
      ),
      body: new SingleChildScrollView(
        child: new Container(
          padding: EdgeInsets.fromLTRB(30.0, 20, 30, 20),
          color: Colors.white,
          width: double.infinity,
          height: MediaQuery.of(context).size.height-kBottomNavigationBarHeight*2,
          alignment: Alignment.topCenter,
          child: new Column(
            children: <Widget>[
              ClipRRect(
                child: Image.asset(
                  'images/btn.png',
                ),
                borderRadius: BorderRadius.circular(10.0),
              ),
              Text(''),
              Text('当前版本:$version'),
              new Container(
                padding: EdgeInsets.fromLTRB(0, 30, 0, 50),
                width: double.infinity,
                child: Html(
                  data: content==null?"":content,
                ),
              ),
              new Container(
                padding: EdgeInsets.fromLTRB(0, 10, 0, 1),
                child: Text('copyright@2018-2019'),
              ),
              new Container(
                padding: EdgeInsets.fromLTRB(0, 10, 0, 20),
                child: Text('南京点墨有限公司'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
